package API.JDK8时间.工具类;
import java.time.LocalDate;
import java.time.Period;

public class period {
    public static void main(String[] args) {
        LocalDate now = LocalDate.now();//获取当前时间对象
        System.out.println(now);

        //设置一个时间
        LocalDate localDate = LocalDate.of(2001, 1, 12);
        System.out.println(localDate);
        Period between=Period.between(localDate,now);//第二个参数减第一个参数
        System.out.println("相差的时间间隔："+between);//P23Y8M23D
        //P23Y8M23D:23Year，8Month，23Day
        System.out.println(between.getYears());//23
    }
}
